<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>物流管理</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：</span>
		基础数据管理 &gt; 物流商管理
</div>

<form action="../../base/logisticsManageController/toPageFinderLogisticInfo.do" method="post" >
<div id="searchbar">
 物流公司名称：<input id="logisticsName" name="logisticsName" type="text" value="${LogisticsInfo.logisticsName}" />
           <input id="btnOK" type="submit" value="查询" class="l-button-search" />
           <input type="button" id="resetBtn" value="重置" class="l-button-search" />
        
</div>
</form>

<div id="maingrid4" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>

<script>
    var basePath='${BasePath}';
    var grid = null;
    $(function () {
    	 // 重置
        $("#resetBtn").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
        grid = $("#maingrid4").ligerGrid({
            columns: [
            { display: '物流公司名称', name: 'logisticsName',width:"12%",align:"left"},
            { display: '物流编码', name: 'logisticsId',width:"8%"},
            { display: '操作', isSort: false,width:"23%", render: function (rowdata, rowindex, value){
                var h = "";
                /*h += "<a href='javascript:setSellByGou(" + rowindex + ")'>运费设置</a> &nbsp;";*/
                /* h += "<a href='javascript:setPoundage(" + rowindex + ")'>手续费设置</a> &nbsp;"; */
                h += "<a href='javascript:detailLogisticInfoCheck(" + rowindex + ")'>查看</a>&nbsp;";
                h += "<a href='javascript:updateLogisticCheck(" + rowindex + ")'>修改</a> &nbsp;";
                h += "<a href='javascript:delLogisticInfoCheck(" + rowindex+ ")'>删除</a>"; 
                return h;
            }
        }
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
					{name: "logisticsName", value:$("#logisticsName").val()}
                    ],
			url: "ajaxPageFinderLogisticInfo.do",
            toolbar: { items: [
                              	{ text: "新增物流", click: addLogisticCheck, icon: "add"}
                              ] }
        });
    });

    
    function addLogisticCheck(){
    	var url=basePath+'/base/logisticsManageController/toAddLogisticInfo.do';
    	url+="?pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab('新增物流','新增物流',url);
    }
    
    function updateLogisticCheck(rowindex){
  	    var codeValue=grid.getData()[rowindex].code;
        var url=basePath+'/base/logisticsManageController/toUpdateLogisticInfo.do?code='+codeValue;
        url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
  	  window.parent.f_addTab('修改物流','修改物流',url);
    }
    
    function detailLogisticInfoCheck(rowindex){
  	    var codeValue=grid.getData()[rowindex].code;
        var url=basePath+'/base/logisticsManageController/detailLogisticInfo.do?code='+codeValue;
        url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
  	  window.parent.f_addTab('物流明细','物流明细',url);
    }
    
    function setSellByDai(rowindex){
  	  var cid=grid.getData()[rowindex].code;
  	  var m=$.ligerDialog.open({title:'代收款设置',url:basePath+'/base/logisticsManageController/toSetAgency.do?code='+cid+'&&settleType='+1,height:350,width:600,isResize: false, isDrag: false });
  	  m.show(); 
    }
    
    function setSellByGou(rowindex){
    	  var cid=grid.getData()[rowindex].code;
    	  var m=$.ligerDialog.open({title:'运费设置',url:basePath+'/base/logisticsManageController/toSetAgency.do?code='+cid+'&&settleType='+2,height:350,width:600,isResize: false, isDrag: false });
    	  m.show(); 
      }
    
    function setPoundage(rowindex){
  	  var cid=grid.getData()[rowindex].code;
  	  var m=$.ligerDialog.open({title:'手续费设置',url:basePath+'/base/logisticsManageController/toSetPoundage.do?code='+cid+'&&settleType='+3,height:350,width:600,isResize: false, isDrag: false });
  	  m.show(); 
    }
    
    function delLogisticInfoCheck(rowindex){
	  	$.ligerDialog.confirm('确定删除?', function (yes) { if(yes){
	    	var logisticsId = grid.getData()[rowindex].logisticsId;
	    	var code = grid.getData()[rowindex].code;
	    	  /*	$.ajax({
		   		 type:'POST',
		   		 url:"../../base/logisticsManageController/checkLogisticCodeByFreight.do",
		   	     data:{"logisticsId":logisticsId},
		   		 success : function(data){
		   			 if(data=="fail")
		   			 {
		   				var s=window.parent.$.ligerDialog.warn("该物流与运费结算有关联，不能删除","提示",function(item, Dialog, index) {
			          		window.location.href = basePath+'/base/logisticsManageController/toPageFinderLogisticInfo.do';
			          		});
			          		$(s.dialog.winbtns).remove();
		   			 }else{
		   				$.post("checkLogisticCodeByCollect.do?logisticsId="+logisticsId,function (data){
		   					if(data == 'fail')
		   					{
		   						var s=window.parent.$.ligerDialog.warn("该物流与代收款结算有关联，不能删除","提示",function(item, Dialog, index) {
					          		window.location.href = basePath+'/base/logisticsManageController/toPageFinderLogisticInfo.do';
					          		});
					          		$(s.dialog.winbtns).remove();
		   					}else{ */
		   						$.post("d_logisticInfo.do?code="+code,function(data){
		   							if(data =='success'){
		   								window.parent.f_tip('删除成功');
		   								reload_cur_tab();
		   							}else{
		   							   window.parent.f_tip('删除失败');
	   								    reload_cur_tab();
		   							}
		   						})
		   					/* }
		   				})
		   		 }
		   	 }
	   	  });*/
	   	 }
	  }); 
    }
 </script>
</body>
</html>